package com.fangcang.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.fangcang.dao.MerchantEntity;
import com.fangcang.dao.MerchantMapper;
import com.fangcang.redis.RedisUtil;

@Service("merchantService")
public class MerchantService {

	@Autowired
	private MerchantMapper mapper;
	
	@Autowired
	private RedisUtil redisUtil;
	
	public  void initMerchantCity() {
		List<MerchantEntity> list = mapper.getList();
		
		Map<String, List<String>> map = new HashMap<String, List<String>>();
		if(!CollectionUtils.isEmpty(list)) {
			list.forEach((m)->{
				if(map.containsKey(m.getMerchantcode())) {
					//map.get(m.getMerchantcode()).add(m.getMerchantcode()+":"+m.getCitycode(), String.valueOf(70));
				}
				redisUtil.hset("PRIORITYS", m.getMerchantcode()+":"+m.getCitycode(), String.valueOf(70));
				
			});
		}
	}
}
